const http = require('http')
const qs = require('querystring');

var user = {
  name: 'wanghao',
  age: 20
}

//server url:http://localhost:3000
var app = http.request({
  protocol: 'http:',
  hostname: 'localhost',
  port: 3000,
  path: '/user?' + qs.stringify(user),
  method: 'GET'
}, (res) => {

  var raw = '';
  res.on('data', (chunk) => {
    raw += chunk;
  })

  res.on('end', (chunk) => {
    console.log(raw)
  })


})
//数据发送
// app.write(qs.stringify(user))
app.end();